/** 
Copyright (c) 2010, Sheikh Abdul Wahid Ahmed
Details @ http://extremecodeworld.codeplex.com/license
**/

using System;
using System.Xml;
using System.IO;
namespace EXtremecode.Utils
{
	/// <summary>
	/// Summary description for XmlUtil.
	/// </summary>
	public class XmlUtil
	{
		public XmlUtil()
		{
			
		}
		public static XmlNodeList GetNodes(XmlElement xmlElement,string xPath,string xmlNamespace,string prefix)
		{
			XmlNamespaceManager manager=new XmlNamespaceManager(xmlElement.OwnerDocument.NameTable);
			manager.AddNamespace(prefix,xmlNamespace);
			return xmlElement.SelectNodes(xPath,manager);
		}

		public static void WriteXml(XmlElement parentElement,string path)
		{
			FileStream fileStream = new FileStream(path,FileMode.Create); 
			XmlTextWriter xmlTextWriter = new XmlTextWriter(fileStream,System.Text.Encoding.UTF8);
			xmlTextWriter.Formatting=Formatting.Indented; 
			parentElement.WriteTo(xmlTextWriter);
			xmlTextWriter.Flush();
			xmlTextWriter.Close();

		}
	}
}
